<form id="_new_wg_cfg" action='index.php?app=site&ctl=admin_theme_widget&act=insert_widget' method='post'>

<{include file="admin/theme/widget/widget_header.html"}>

<div class="table-action">
	<{button type="submit" id="on_submit" label=$___a="添加"|t:'site'}>
</div>

</form>
<script>
  $('_new_wg_cfg').addEvent('submit',function(e){
    e=new Event(e).stop();
    //<{t}>指向框架内对象<{/t}>
    //<{t}>验证输入<{/t}>
	//<{t}>暂时不验证<{/t}>2010/5/14 edwin todo
    //if(!this.bindValidator('_x_ipt'))return;


    $ES('textarea[ishtml=true]',this).getValue();

    var frameWin=$('themeFrame').contentWindow;

    var shopWidgets=frameWin.shopWidgets;
    //<{t}>临时容器<{/t}>
	
    var wg=frameWin.document.newElement('div');
	
	
    var temId=$time()+$random(100,999);
	if(!wg)return;
    $(wg).setProperty('id','wg'+$time());
    this.action+='&widgets=<{$widgetsType}>&domid='+temId+'&widgets_app=<{$widgetsApp}>&widgets_theme=<{$widgetsTheme}>&theme=<{$theme}>';
    
    new Request({url:this.action,data:this,method:this.get('method'),onSuccess:function(re){
        wg.setHTML(re);
        wg= wg.getFirst();
        wg.setProperty('id',temId);
		
        wg.setProperty('widgets_id', 'tmp_' + '<{$i}>');
        var sw_curDrop=shopWidgets.curDrop;
		
        wg.injectTop(sw_curDrop);
        
        shopWidgets.drags.include($(wg));
        shopWidgets.initDrags([wg]);
        shopWidgets.checkEmptyDropPanel(sw_curDrop);
        shopWidgets.curdialog.close();
    }}).send();
    
  });
</script>